package com.yeyaomai.dksns.flowis.servlet;

import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import com.yeyaomai.dksns.flowis.domain.Feedback;
import com.yeyaomai.dksns.flowis.domain.flowisdetail.FlowisQueryOrder;
import com.yeyaomai.dksns.flowis.service.FeedbackService;

/**
 * @content 用户反馈处理类
 * @author xiaqin
 * @date 2012-07-12
 */
@Controller
@RequestMapping("/feedback/*")
public class FeedbackController {

	@Autowired
	private FeedbackService feedbackService;

	@RequestMapping(value = "/getFeedback")
	public String getFeedback(HttpServletRequest request,
			HttpServletResponse response, FlowisQueryOrder order,
			ModelMap modelMap) {

		Page<Feedback> feedbackPage = feedbackService.getSplit(order);
		modelMap.addAttribute("feedbackPage", feedbackPage);
		modelMap.addAttribute("messageTypeMap", messageType());
		return "feedbacklist";
	}
	
	@RequestMapping(value = "/detail")
	public String getFeedback(HttpServletRequest request,
			HttpServletResponse response, ModelMap modelMap) {

		String id= request.getParameter("id");
		Feedback feedback = feedbackService.getFeedbackById(Long.valueOf(id));
		modelMap.addAttribute("feedback", feedback);
		modelMap.addAttribute("messageTypeMap", messageType());
		return "feedbackdetail";
	}
	
	public Map<String, String> messageType(){
		
		Map<String, String> typeMap = new HashMap<String, String>();
		typeMap.put("0", "个人账户");
		typeMap.put("1", "主页功能");
		typeMap.put("2", "网页功能");
		typeMap.put("3", "搜索问题");
		typeMap.put("4", "应用问题");
		typeMap.put("5", "支付问题");
		typeMap.put("6", "广告系统");
		typeMap.put("7", "开放平台");
		typeMap.put("8", "手机客户端");
		return typeMap;
	}
}
